<template>
  <div id="recorddialog">
    <!--    <commonformdialog :isshowDialogs="isshowDialog" :isshowconfirmbtn="false" :dialogWidth="'80%'" :enterTitle="false"
      :isshowimportTitle="false" :dialogTitle="`练车券-${dialogparams.titlename}`" @closetextDialog="closetextDialog"
      @confirmbtn='confirmbtn'>
      <div class="innerloding">
        <el-table :data="tableData.list" border style="width: 100%">
          <el-table-column prop="team_id" label="限用机构" show-overflow-tooltip align="center"></el-table-column>
          <el-table-column prop="coach_id" label="限用教练" align="center"></el-table-column>
          <el-table-column prop="subject" label="限用科目" align="center"></el-table-column>
          <el-table-column prop="use_num" label="可用次数" align="center"></el-table-column>
          <el-table-column prop="hand_out_user" label="派发人员" align="center"></el-table-column>
          <el-table-column prop="start_time" label="开始时间" show-overflow-tooltip align="center"></el-table-column>
          <el-table-column prop="end_time" label="结束时间" show-overflow-toolti align="center"></el-table-column>
          <el-table-column prop="update_time" label="最近使用时间" show-overflow-tooltip align="center">
            <template slot-scope="scope">
              <span>
                {{scope.row.create_time==scope.row.update_time?'-':scope.row.update_time}}
              </span>
            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-col :span="24" class="pagination">

            <el-pagination class="fr" @size-change="handleSizeChange" @current-change="handleCurrentChange"
              :current-page="tableData.page.page" :page-sizes="[8]" :page-size="8" background layout="total, sizes, prev, pager, next"
              :total="tableData.page.total"></el-pagination>
          </el-col>
        </el-row>
      </div>
    </commonformdialog> -->
    <commonformdialog :isshowDialogs="isshowDialog" :isshowconfirmbtn="false" :dialogWidth="'60%'" :enterTitle="false"
      :isshowimportTitle="false" :dialogTitle="`练车券-${dialogparams.titlename}`" @closetextDialog="closetextDialog" @confirmbtn='confirmbtn'>
      <div class="innerloding">
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column prop="team_id" label="限用机构" show-overflow-tooltip align="center"></el-table-column>
          <el-table-column prop="coach_id" label="限用教练" align="center">
            <template slot-scope="scope">
              <span>
                {{scope.row.coach_id=='-'?'所有教练':scope.row.coach_id}}
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="subject" label="限用科目" align="center"></el-table-column>
          <el-table-column prop="use_num" label="可用次数" align="center"></el-table-column>
          <el-table-column prop="hand_out_user" label="派发人员" align="center"></el-table-column>
          <el-table-column prop="start_time" label="开始时间" show-overflow-tooltip align="center"></el-table-column>
          <el-table-column prop="end_time" label="结束时间" show-overflow-toolti align="center"></el-table-column>
          <el-table-column prop="update_time" label="最近使用时间" show-overflow-tooltip align="center">
            <template slot-scope="scope">
              <span>
                {{scope.row.create_time==scope.row.update_time?'-':scope.row.update_time}}
              </span>
            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-col :span="24" class="pagination">
            <!-- 翻页 -->
            <el-pagination class="fr" @size-change="handleSizeChange" @current-change="handleCurrentChange"
              :current-page="pages.page" :page-sizes="[5]" :page-size="5" background layout="total, sizes, prev, pager, next"
              :total="pages.total"></el-pagination>
          </el-col>
        </el-row>
      </div>

    </commonformdialog>
  </div>
</template>

<script>
  //引入弹窗
  import commonformdialog from '@/components/commondialog/commondialog'
  //api
  import {
    getSessionStorage
  } from '@/utils/accessToken'
  import Treeselect from "@riophae/vue-treeselect"; //下拉树组件
  import {
    studentHandoutticket,
    studentGetticket
  } from '@/api/student'
  export default {
    data() {
      return {
        //标题名字
        titlename: '',
        //表格数据
        tableData: [],
        //页码数据
        pages: {},
        //id
        studentid: '',
        //成绩记录页码
        rpage: 1,
        //成绩记录一页多少数据
        rtotal: 5,
      }
    },
    components: {
      commonformdialog,
    },
    props: {
      //是否显示弹窗
      isshowDialog: {
        type: Boolean,
        default: false,
      },
      //点击传递的参数
      dialogparams: {
        type: Object,
        default: () => {
          return {}
        }
      },
    },
    methods: {
      //获取成绩记录列表数据
      //
      async getrecordList() {
        let {
          subject,
          user_id,
          student_id
        } = this.getparams
        let params = {
          subject,
          user_id,
          student_id
        }
        params.page = this.rpage
        params.rows = this.rtotal
        let data = await studentGetticket(params)
        console.log(data)
        if (data.code == '0000') {
       this.tableData = data.data.list
       this.pages = data.data.page
          console.log(this.tableData)
        }
      },
      //一页多少数据翻页
      handleSizeChange(val) {
        this.rtotal = val
        this.getrecordList()
      },
      handleCurrentChange(val) {
        this.rpage = val
        this.getrecordList()
      },
      //关闭弹窗
      closetextDialog() {
        this.$emit('closetextDialog')
      },
      //点击确认
      confirmbtn() {
        this.$emit('closetextDialog')
      }
    },
    watch: {
      dialogparams(val) {
        this.studentid = val.id
        this.titlename = val.name
        this.getparams=val
      },
      isshowDialog(val) {
        if (val) {
          this.getrecordList()
        }
      }
    }


  }
</script>

<style scoped lang='scss'>

</style>
